package threadTest.callable;

import threadTest.thread.Window;

import java.util.concurrent.Callable;

import static java.lang.Thread.sleep;

/**
 * @author zyc
 * @create 2022--05--13 11:42
 */
public class Window2 implements Callable {
    private static int ticket = 100;

    @Override
    public Object call(){
        while (true) {
//            try {
//                sleep(100);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }

                if(ticket>0){
                    System.out.println(Thread.currentThread().getName()+"当前售出第"+ticket+"张票");
                    ticket--;
                }else{
                    break;
                }

        }
        return Thread.currentThread().getName() + "结束";
    }
}
